package beans;

import java.io.Serializable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

import java.util.Map;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;

import oracle.adf.view.rich.component.rich.layout.RichPanelSplitter;
import oracle.adf.view.rich.context.AdfFacesContext;

import oracle.binding.OperationBinding;

public class LanguageBB implements Serializable {
    private static final long serialVersionUID = 1L;
    private String language;
     oracle.adf.view.rich.component.rich.layout.RichPanelSplitter  panel;
  
    public LanguageBB() {
       language = Locale.getDefault().getLanguage();
      
    }

    private void changeLocale(String language) {
        this.language = language;
        Locale newLocale = new Locale(this.language);
        FacesContext context = FacesContext.getCurrentInstance();
        context.getViewRoot().setLocale(newLocale);
        Locale.setDefault(newLocale);
        
        AdfFacesContext adfFacesContext=AdfFacesContext.getCurrentInstance();
        adfFacesContext.addPartialTarget(panel);
        System.out.println("changeLocale"+language);
    }

    public void setLanguage(String language) {
       this.language = language;
    }

    public String getLanguage() {
        return language;
    }
    public void localeChangeListener(ValueChangeEvent valueChangeEvent) {
        changeLocale(valueChangeEvent.getNewValue().toString());
    }

    public RichPanelSplitter getPanel() {
        return panel;
    }

    public void setPanel(RichPanelSplitter panel) {
        this.panel = panel;
    }
}
